﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FileNameChangeApplication3._0
{
    public class ZdxxMessage
    {
        public string zdh="";
        public string dhhm = "";
        public string jfnd = "";
        public string yhzgx = "";
        public string yyqlrgx = "";
        public string bz1 = "";
        public string bz2 = "";
        public string xzzd = "0";

        public static int CREAT_BY_FILE = 1;
        public static int CREAT_BY_ZDH = 2;

        public ZdxxMessage(string path)
        {

            try
            {
                StreamReader fileReader = new StreamReader(path);
                Dictionary<string, string> fileContent = new Dictionary<string, string>();
                string[] rowContent;
                string line = "";
                while ((line = fileReader.ReadLine()) != null)
                {
                    rowContent = line.Split(':');
                    if (rowContent[1] == null)
                    {
                        fileContent.Add(rowContent[0], "");
                    }
                    else
                    {
                        fileContent.Add(rowContent[0], rowContent[1]);
                    }
                }
                fileReader.Close();
                zdh = fileContent["宗地号"].Trim();
                dhhm = fileContent["电话号码"].Trim();
                jfnd = fileContent["建房年代"].Trim();
                yhzgx = fileContent["与户主关系"].Trim();
                yyqlrgx = fileContent["与原权利人关系"].Trim();
                bz1 = fileContent["备注1"].Trim();
                bz2 = fileContent["备注2"].Trim();
                xzzd = fileContent["新增宗地"].Trim();

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
        }
        public ZdxxMessage(string path,string newZdh)
        {
            string filePath = path + "\\message.txt" ;
            TxtHelper.txtWrite(filePath, "宗地号:" + newZdh + "\r\n");
            TxtHelper.txtWrite(filePath, "电话号码:" + "\r\n");
            TxtHelper.txtWrite(filePath, "建房年代:" + "\r\n");
            TxtHelper.txtWrite(filePath, "与户主关系:" + "\r\n");
            TxtHelper.txtWrite(filePath, "与原权利人关系:" + "\r\n");
            TxtHelper.txtWrite(filePath, "备注1:" + "\r\n");
            TxtHelper.txtWrite(filePath, "备注2:" + "\r\n");
            TxtHelper.txtWrite(filePath, "新增宗地:0" + "\r\n");
            zdh = newZdh;
        }
    }
}
